/*
 * jxUtils Project (2013, 2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxUtils.system;

import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JComponent;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxUtils
 * @package org.jxUtils.system
 * @date 22/11/2014 - 10:45:23
 */
public final class ScreenUtil {
	
	/**
	 * @return printScreen
	 * @throws AWTException
	 */
	public static ImageIcon getPrintScreen() throws AWTException {
	
		return new ImageIcon(new Robot().createScreenCapture(new Rectangle(getScreenSize())));
	}
	
	/**
	 * @param component
	 *        printScreen
	 * @return imageIcon
	 * @throws AWTException
	 */
	public static ImageIcon getPrintScreen(final JComponent component) throws AWTException {
	
		//
		return new ImageIcon(new Robot().createScreenCapture(new Rectangle(component.getLocationOnScreen(), component.getSize())));
	}
	
	/**
	 * @return screenSize
	 */
	public static Dimension getScreenSize() {
	
		return Toolkit.getDefaultToolkit().getScreenSize();
	}
	
	/**
	 * @return screenResolution
	 */
	public static int getScreenResolution() {
	
		return Toolkit.getDefaultToolkit().getScreenResolution();
	}
	
	/**
	 * @return screenSize
	 */
	public static String getScreenResolutionInString() {
	
		return getScreenResolution() + " DPI";
	}
	
	/**
	 * @return screenSize
	 */
	public static String getScreenSizeInString() {
	
		Dimension dimension = getScreenSize();
		
		return dimension.width + "x" + dimension.height;
	}
}
